/*
* Tabs 3 - New Wave Tabs
*
* Copyright (c) 2007 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*/
(function($) {
// if the UI scope is not availalable, add it
$.ui = $.ui || {};
// tabs initialization
$.fn.tabs = function(initial, options) {
if (initial && initial.constructor == Object) { // shift arguments
options = initial;
initial = null;
}
options = options || {};
initial = initial && initial.constructor == Number && --initial || 0;
return this.each(function() {
new $.ui.tabs(this, $.extend(options, { initial: initial }));
});
};
// other chainable tabs methods
$.each(['Add', 'Remove', 'Enable', 'Disable', 'Click', 'Load', 'Href'], function(i, method) {
$.fn['tabs' + method] = function() {
var args = arguments;
return this.each(function() {
var instance = $.ui.tabs.getInstance(this);
instance[method.toLowerCase()].apply(instance, args);
});
};
});
$.fn.tabsSelected = function() {
var selected = -1;
if (this[0]) {
var instance = $.ui.tabs.getInstance(this[0]),
$lis = $('li', this);
selected = $lis.index( $lis.filter('.' + instance.options.selectedClass)[0] );
}
return selected >= 0 ? ++selected : -1;
};
// tabs class
$.ui.tabs = function(el, options) {
this.source = el;
this.options = $.extend({
// basic setup
initial: 0,
event: 'click',
disabled: [],
cookie: null, // pass options object as expected by cookie plugin: { expires: 7, path: '/', domain: 'jquery.com', secure: true }
// TODO bookmarkable: $.ajaxHistory ? true : false,
unselected: false,
unselect: options.unselected ? true : false,
// Ajax
spinner: 'Loading…',
cache: false,
idPrefix: 'tab-',
// animations
/*fxFade: null,
fxSlide: null,
fxShow: null,
fxHide: null,*/
fxSpeed: 'normal',
/*fxShowSpeed: null,
fxHideSpeed: null,*/
// callbacks
add: function() {},
remove: function() {},
enable: function() {},
disable: function() {},
click: function() {},
hide: function() {},
show: function() {},
load: function() {},
// templates
tabTemplate: '